<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
class Dispatch extends CI_Controller {
	public function __construct() {
		parent::__construct ();
		/*if (! $this->session->userdata ( 'logged_in' )||$this->session->userdata ( 'type')!=1) {
			redirect ( 'index_admin/login' );
			exit ();
		}*/
	}
	/*
	 * 车辆调度页面
	 */
	public function index() {
		$date = $this->uri->segment ( 4 );
		$this->load->model ( 'order_model' );
		$users = $this->order_model->find_order_users ($date);
		$data ['amount'] = count($users);
		$data ['users'] = $users;
		$this->load->view ( 'dispatch/index' ,$data);
	}
	/*
	 * 返回所有下过单的饭店位置
	 */
	public function allposition() {
		$this->load->model ( 'order_model' );
		$users = $this->order_model->find_order_position_users ();
		$data ['amount'] = count($users);
		$data ['users'] = $users;
		$this->load->view ( 'dispatch/index' ,$data);
	}
	/*
	 * 根据起始日期返回下过单的饭店位置
	 */
	public function position() {
		$startdate = $this->uri->segment ( 4 );
		$enddate = $this->uri->segment ( 6 );
		$startdate=date ( "Y-m-d", strtotime ($startdate));
		$enddate=date ( "Y-m-d", strtotime ($enddate));
		$this->load->model ( 'order_model' );
		$users = $this->order_model->find_order_position_users_by_date ($startdate,$enddate);
		$data ['amount'] = count($users);
		$data ['users'] = $users;
		$this->load->view ( 'dispatch/index' ,$data);
	}
}